home *** CD-ROM | disk | FTP | other *** search
- ComboBox Notes
-
- The Combo unit defines a Turbo Vision view I call TComboBox. The
- purpose of TComboBox is simple: to provide a "pull down" list box
- associated with a standard TInputLine allowing you to pick an item off
- the list and put it into the input line. The ComboBox looks and
- functions a lot like the Turbo Vision History List. It even uses the
- same palette. The difference is, the History List displays a limited
- number of unsorted strings, while the ComboBox displays an essentially
- unlimited number of sorted strings.
-
- To use the combo box, you need a standard TInputLine, and a
- TComboCollection to display in the pull down window. A
- TComboCollection is a TSortedCollection which has the added capability
- of providing a pointer to a string associated with each item.
-
- You probably need to override the TxtPtr function to provide a pointer
- to the string in each item which should be displayed in the window.
- The default TxtPtr assumes that the item pointer returned by the
- collection's At function points at the string to display.
-
- Now simply instantiate the combo box beside the associated input line
- in your dialog. For example:
-
- var
- MyList : PComboCollection;
- Bounds : TRect;
- L : PInputLine;
- .
- .
- .
- Bounds.Assign(5,5,20,6);
- L := New(PInputLine, Init(Bounds, 15));
- Insert(L);
- Bounds.Assign(20,5,23,6);
- Insert(New(PComboBox, Init(Bounds, L, MyList)));
-
- See the file COMBODEM.PAS for a working complete example.
-
- To display the list associated with the Input Line, simply click the
- ComboBox icon to the right of the input line, or press the down arrow
- key while the input line is focused. The list has a couple of
- not-so-obvious features. Moving to the desired item in the list may be
- done very quickly by taking advantage of the "power typing" feature.
- With the list pulled down, begin typing the desired item just as it
- appears in the list (case sensitive). The focus will "zero in" on the
- item as each character is typed. As soon as the item is highlighted,
- you may select it by pressing Return, Tab, or double clicking it with
- the mouse. The selected string will be placed into the input line. If
- Tab was pressed, the focus is immediately moved to the next selectable
- view in the dialog, otherwise, the input line retains the focus. A
- right mouse button click will cancel the list without changing the
- input line contents, as will pressing Escape, or clicking the List's
- close icon.
-
- I hope you find ComboBox useful. The source is included in the spirit
- of encouraging more Turbo Vision applications development. Enjoy.
-
- Author: Keith Greer
- 68 Tamworth Rd.
- Troy, OH 45373-1551
-
- C'Serve ID: 73457,3042
- Internet: greerk@wpdis11.hq.aflc.af.mil
-